// Ninf-G-XX, ver. 0.1
// Copyright 2011 National Institute of Advanced Industrial Science and Technology
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __NC_TYPES_H__
#define __NC_TYPES_H__

namespace ninf { 
	namespace gen { 
		enum GenExprCode {
			ERROR_NODE      = 0,
			LIST            = 1,
			IDENT           = 2,
			STRING_CONSTANT = 3,
			INT_CONSTANT    = 4,
			LONG_CONSTANT   = 5,
			FLOAT_CONSTANT  = 6,
			BASIC_TYPE_NODE = 7,
			MODE_SPEC_NODE  = 8,
			
			PLUS_EXPR       = 35,
			MINUS_EXPR      = 37,
			UNARY_MINUS_EXPR= 39,
			MUL_EXPR        = 40,
			BEKI_EXPR       = 41,
			DIV_EXPR        = 42,
			MOD_EXPR        = 44,
			
			EQ_EXPR         = 50,
			NEQ_EXPR        = 51,
			GT_EXPR         = 52,
			LT_EXPR         = 53,
			GE_EXPR         = 54,
			LE_EXPR         = 55,
			TRY_EXPR        = 56,
			
			POINTER_REF     = 66,
			ARRAY_REF       = 67,
			CALLBACK_FUNC   = 68
		};
	
		enum GenSymbolType
			{
				S_IDENT=0,	/* default */
				S_TYPE,
				S_CLASS,
				S_KEYWORD
			};
		
	

		enum GenBackend{
			BACKEND_NORMAL,
			BACKEND_MPI,
			BACKEND_BLACS
		};

		enum ExpOp {
			OP_VALUE_PLUS     = 1,
			OP_VALUE_MINUS    = 2,
			OP_VALUE_MUL      = 3,
			OP_VALUE_DIV      = 4,
			OP_VALUE_MOD      = 5,
			OP_VALUE_UN_MINUS = 6,
			OP_VALUE_BEKI     = 7,
			OP_VALUE_EQ       = 8,    /*  ==  */
			OP_VALUE_NEQ      = 9,    /*  !=  */
			OP_VALUE_GT       = 10,   /*  >  */
			OP_VALUE_LT       = 11,   /*  <  */
			OP_VALUE_GE       = 12,   /*  >=  */
			OP_VALUE_LE       = 13,   /*  <=  */
			OP_VALUE_TRY      = 14    /*  ? : */
		};
	}
	namespace lib {
		
enum ExpEntryTag {
    VALUE_NONE      = 0, /* default */
    VALUE_CONST     = 1, /* default, give by constant */
    VALUE_IN_ARG    = 2, /* specified by IN scalar paramter */
    VALUE_OP        = 3, /* operation code */
    VALUE_END_OF_OP = 4, /* end of expression, terminator */

    VALUE_IN_HEADER = 5  /* for unspecified size */
};



enum DataType {
    DT_UNDEF,	/* undefined */
    DT_VOID,
    DT_CHAR,
    DT_SHORT,
    DT_INT,
    DT_LONG,
    DT_FLOAT,
    DT_DOUBLE,
    DT_STRING_TYPE,
    DT_SCOMPLEX,
    DT_DCOMPLEX,
    DT_FILENAME,
    BASIC_TYPE_END
};

#ifndef DataNames_OWNER
extern const char * DataNames[];
extern const char * DataCNames[];
extern int    DataSize[];
#else
const char * DataNames[] = {
    "DT_UNDEF",
    "DT_VOID",
    "DT_CHAR",
    "DT_SHORT",
    "DT_INT",
    "DT_LONG",
    "DT_FLOAT",
    "DT_DOUBLE",
    "DT_STRING_TYPE",
    "DT_SCOMPLEX",
    "DT_DCOMPLEX",
    "DT_FILENAME",
};

const char * DataCNames[] = {
    "",
    "void",
    "char",
    "short",
    "int",
    "long",
    "float",
    "double",
    "char *",
    "float *",
    "double *",
    "char *",
};


int    DataSize[] = {
  0,
  0,
  sizeof(char),
  sizeof(short),
  sizeof(int),
  sizeof(long),
  sizeof(float), 
  sizeof(double),
  sizeof(char *),
  sizeof(float) * 2,
  sizeof(double) * 2,
  sizeof(char *)
};
#endif

enum ModeType {
    MODE_NONE  = 0,
    MODE_IN    = 1,
    MODE_OUT   = 2,
    MODE_INOUT = 3,
    MODE_WORK  = 4       /* mode for work space */
};

#ifndef ModeNames_OWNER
extern const char * ModeNames[];

#else
const char * ModeNames[] = {
    "MODE_NONE", 
    "MODE_IN", 
    "MODE_OUT",
    "MODE_INOUT",
    "MODE_WORK"
};
#endif


#ifndef OpNames_OWNER
extern const char * OpNames[];

#else
const char * OpNames[] = {
    "",
    "OP_VALUE_PLUS", 
    "OP_VALUE_MINUS",
    "OP_VALUE_MUL",
    "OP_VALUE_DIV",
    "OP_VALUE_MOD",
    "OP_VALUE_UN_MINUS",
    "OP_VALUE_BEKI",
    "OP_VALUE_EQ",
    "OP_VALUE_NEQ",
    "OP_VALUE_GT",
    "OP_VALUE_LT",
    "OP_VALUE_GE",
    "OP_VALUE_LE",
    "OP_VALUE_TRY"
};
#endif
}
}

#endif
